using Keyki.XNAGameEngine.Common.Console;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Keyki.XNAGameEngine
{
	public class Engine
	{
		//TODO: for release implement binary serialization instead of XML
		//TODO: implement FPS counter and memory use manager
		//TODO: implement Lua interpretation for Console
		//TODO: add PgUp/PgDown and Mouse Scroll support for console class
		//TODO: add copy/paste support for console class

		private readonly Game m_game;
		private XnaConsole m_console;
		private GameObjectManager m_manager;

		public Engine(Game game)
		{
			m_game = game;
		}

		/// <summary>
		/// Init engine class
		/// </summary>
		public void Init()
		{
#if DEBUG
			m_game.Window.AllowUserResizing = true;
			m_game.IsMouseVisible = true;
#endif
			var consoleFont = m_game.Content.Load<SpriteFont>("ConsoleFont");
			m_console = new XnaConsole(m_game, consoleFont);

			AddComponent(m_console);
		}

		/// <summary>
		/// Load content according to XML
		/// </summary>
		/// <param name="path">path to config XML file</param>
		public void LoadContent(string path)
		{
			//Call Parser and create objects
		}

		#region private Methods

		private void AddService<T>(T service)
		{
			m_game.Services.AddService(service.GetType(), service);
		}

		private void AddComponent(IGameComponent item)
		{
			m_game.Components.Add(item);
		}

		#endregion
	}
}